package com.hhsjdesign.dynamicui.core.widgetimpl

import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import com.hhsjdesign.dynamicui.businessdata.IViewable
import com.hhsjdesign.dynamicui.core.widgetdata.WidgetData

abstract class BusinessWidget : IWidget {
    //数据来源，0 表示本地， 1 表示 网络
    var sourceType: Int = 0;

    //数据
    var items: MutableList<IViewable<*>>? = null

    constructor(context: Context, widgetData: WidgetData) : super(context, widgetData) {
        sourceType = widgetData.dataSource
        if (sourceType == 0) {
            items = widgetData.businessData
        }
    }

    //直接操作数据
    open fun loadLocalBusiness() {

    }

    //请求数据
    open fun loadRemoteBusiness() {
//        val listener = object : RequestListener<Any> {
//            override fun onRequestSuccess(
//                result: BaseModel<Any>
//            ) {
//            }
//
//            override fun onRequestFail(resultCode: Int, resultMessage: String) {
//            }
//
//        }
//
//        dataCaller?.loadData(
//            widgetData.business!!, widgetData.params!!,
//            this,
//            listener
//        )
    }

    override fun onLoadData() {
        //本地数据
        if (sourceType == WidgetData.SOURCE_TYPE_FIXED) {
            loadLocalBusiness()
            return
        }
        loadRemoteBusiness()
    }

    override fun displayBg(imageView: ImageView, url: String) {

    }

    override fun cancelPlayBg() {

    }

    override fun updateLayoutParam(viewGroup: ViewGroup.LayoutParams) {

    }

}